<?php
switch($action){
	/************************************** friendlink BEGIN ************************************************/
	case "friendlink":
	$rows=$db->row_select("links","",0,"*","ordernum");
	$dwidth=array(0,50,80,150,150,250,150);

echo <<<EOT
<script>
var maxIndex=0;
function addFriendLink(linkid, ordernum, linkname, url, content, logo){
	var namepre='links';
	if(linkid==''){
		namepre='newlinks';
	}
	var s="<table class=\"table_1\" width=\"100%\"><tr><td class=\"td_6\"><div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\"><input type=\"checkbox\" value=\""+linkid+"\" name=\""+namepre+"_delid[]\" class=\"checkbox_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\"><input type=\"text\" size=\"6\" value=\""+ordernum+"\" name=\""+namepre+"_ordernum["+linkid+"]\" class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\"><input type='text' value='"+linkname+"' size='20' name='"+namepre+"_name["+linkid+"]' class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\"><input type='text' value='"+url+"' size='20'  name='"+namepre+"_url["+linkid+"]' class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[5]}px;\"><input type='text' value='"+content+"' size='30' name='"+namepre+"_content["+linkid+"]' class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[6]}px;\"><input type='text' value='"+logo+"' size='20' name='"+namepre+"_logo["+linkid+"]' class=\"text_css\" /></div></td></tr></table>";
	var ele=document.createElement('div');
	ele.id="group_div_"+maxIndex;
	ele.innerHTML=s;
	E("linksdiv").appendChild(ele);
	maxIndex++;
}
</script>

	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="linksform" onsubmit="return false;">
		<div class="tips_1"><b>提示</b><br />
	* 有填写LOGO的友情链接，将会显示图标；否则只显示链接名称。<br /></div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1" width="100%">
			<tr style="font-weight:bold;color:#333333;"><td class="td_6"><div class="rowdiv_0" style="width:{$dwidth[1]}px;"><span class="warning">删除</span></div><div class="rowdiv_0" style="width:{$dwidth[2]}px;">显示顺序</div><div class="rowdiv_0" style="width:{$dwidth[3]}px;">链接名称</div><div class="rowdiv_0" style="width:{$dwidth[4]}px;">URL</div><div class="rowdiv_0" style="width:{$dwidth[5]}px;">说明</div><div class="rowdiv_0" style="width:{$dwidth[6]}px;">LOGO</div></td></tr>
		</table>
		<div id="linksdiv">
EOT;
			for($i=0;$i<count($rows);$i++){
				$row=$rows[$i];
				echo("<script>addFriendLink(\"{$row['id']}\",\"{$row['ordernum']}\",\"{$row['name']}\",\"{$row['url']}\",\"{$row['content']}\",\"{$row['logo']}\");</script>");			
			}
			
echo <<<EOT
		</div>
			<table class="table_1" width="100%">
			<tr><td class="td_6"><a class="td_5_1a" href="javascript:addFriendLink('','','','','','')"><img src="images/ico_add.gif" border="0" /> 添加链接</a></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_links()" /></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>
var hasErr=false;
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","友情链接","",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();

function ajax_links(){
	popwin.loading();
	ajaxPost("linksform","ad_ajax.php?action=savelinks",ajax_links_callback);
}
function ajax_links_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"编辑成功","友情链接修改成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** friendlink END ************************************************/

	/************************************** view BEGIN ************************************************/
	case "view":
	$adtypes=array("","页头通栏广告","底部通栏广告","页内文字广告","帖内文字广告");
	$adtype=numFilter($_GET['adtype']);
	$rows=$db->row_select("ads","adtype={$adtype}",0,"*","ordernum");
	$dwidth=array(0,40,40,80,150,150,300,150);

echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="adallform" onsubmit="return false;">
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1" width="100%">
			<tr style="font-weight:bold;color:#333333;"><td class="td_6"><div class="rowdiv_0" style="width:{$dwidth[1]}px;"><span class="warning">删除</span></div><div class="rowdiv_0" style="width:{$dwidth[2]}px;">启用</div><div class="rowdiv_0" style="width:{$dwidth[3]}px;">显示顺序</div><div class="rowdiv_0" style="width:{$dwidth[4]}px;">广告名称</div><div class="rowdiv_0" style="width:{$dwidth[5]}px;">广告类型</div><div class="rowdiv_0" style="width:{$dwidth[6]}px;">广告显示时间</div><div class="rowdiv_0" style="width:{$dwidth[7]}px;">操作</div></td></tr>
		</table>
		<div id="linksdiv">
EOT;
			for($i=0;$i<count($rows);$i++){
				$row=$rows[$i];
				$adid=$row['id'];
				$row['starttime']=empty($row['starttime'])?"无限制":getDateStr($row['starttime'],'dateonly',false);
				$row['stoptime']=empty($row['stoptime'])?"无限制":getDateStr($row['stoptime'],'dateonly',false);
				$checkstr=($row['isuse']==1?' checked=true':'');
				echo("<table class=\"table_1\" width=\"100%\"><tr><td class=\"td_6\"><div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\"><input type=\"checkbox\" value=\"{$adid}\" name=\"delid[]\" class=\"checkbox_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\"><input type=\"checkbox\" value=\"1\" name=\"isuse[{$adid}]\"{$checkstr}  class=\"checkbox_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\"><input type=\"text\" value=\"{$row['ordernum']}\" size=\"6\" name=\"ordernum[{$adid}]\" class=\"text_css\" /></div><div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">{$row['adname']}</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[5]}px;\">{$adtypes[$row['adtype']]}</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[6]}px;\">{$row['starttime']} <span style='color:#999999;'>~</span> {$row['stoptime']}</div><div class=\"rowdiv_0\" style=\"width:{$dwidth[7]}px;\"><a href=\"admin.php?inc=ad&action=edit&id={$adid}\">编辑</a></div></td></tr></table>");			
			}
			
echo <<<EOT
		</div>
			<table class="table_1" width="100%">
			<tr><td class="td_6"><a class="td_5_1a" href="admin.php?inc=ad&action=edit&adtype={$adtype}"><img src="images/ico_add.gif" border="0" /> 添加广告</a></td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提  交  " onclick="ajax_adall()" /></td></tr>
		</table>
		</form>
	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>
var adtypes=["","页头通栏广告","底部通栏广告","页内文字广告","帖内文字广告"];
var adtype={$adtype};
var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1",adtypes[adtype],"",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();

function ajax_adall(){
	popwin.loading();
	ajaxPost("adallform","ad_ajax.php?action=saveadall&adtype="+adtype, ajax_adall_callback);
}
function ajax_adall_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"编辑成功","广告修改成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** view END ************************************************/


	/************************************** edit BEGIN ************************************************/
	case "edit":	//广告
	$adtype=numFilter($_GET['adtype']);
	$id=numFilter($_GET['id']);
	if(!empty($id)){
		$row=$db->row_select_one("ads","id={$id}");
		$row['starttime'] = empty($row['starttime']) ? '':getDateStr($row['starttime'],'dateonly',false);
		$row['stoptime'] = empty($row['stoptime']) ? '': getDateStr($row['stoptime'],'dateonly',false);
	}
echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="adform" onsubmit="return false;">
		<div class="tips_1"><b>广告添加/编辑</b><br />
		* 点击图片可以查看广告的位置/效果图。
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">广告类别:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><select style="width:280px;" id="ad[adtype]" name="ad[adtype]"><option value="1">页头通栏广告</option><option value="2">底部通栏广告</option><option value="3">页内文字广告</option><option value="4">帖内文字广告</option></select></td><td class="td_2">选择广告的类别</td></tr>
			<tr><td class="td_0">广告名称:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="43" name="ad[adname]" id="ad[adname]" value="{$row['adname']}" class="text_css" /></td><td class="td_2">广告名称只为识别辨认不同广告条目之用，并不在广告中显示</td></tr>
			<tr><td class="td_0">广告投放范围:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><select size="10" multiple="multiple" style='width:280px;' name="ad[targets]" id="ad[targets]"><option value="all">全部</option><option value="index">首页</option>{$cache_forumsoption2}</select></td><td class="td_2">设置显示的范围，可以按住 CTRL 多选</td></tr>
			<tr><td class="td_0">广告显示时间:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="18" name="ad[starttime]" id="ad[starttime]" onfocus="choosedate.dfd(E('ad[starttime]'))"  value="{$row['starttime']}" class="text_css" /> ~ <input type="text" size="18" name="ad[stoptime]" id="ad[stoptime]" onfocus="choosedate.dfd(E('ad[stoptime]'))" value="{$row['stoptime']}" class="text_css" /></td><td class="td_2">设置广告显示的时间，格式 yyyy-mm-dd，留空为不限制时间</td></tr>
			
			<tr><td class="td_0">广告内容:(支持HTML)</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="width:280px;height:100px;" name="ad[code]" id="ad[code]">{$row['code']}</textarea></td><td class="td_2">请直接输入需要展现的广告的 HTML 代码</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提 交  " onclick="ajax_editad()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var smallNowTab;
	var id="{$id}";
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","广告添加/编辑","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();

	setSelect("ad[adtype]",{$adtype});
	if(id!=""){
		setSelect("ad[adtype]","{$row['adtype']}");
		var targets="{$row['targets']}";
		var ts=targets.split(",");
		for(var i=0;i<ts.length;i++){
			setSelect("ad[targets]",ts[i]);
		}
	}


function ajax_editad(){
	if(getV("ad[adname]")==""||getV("ad[targets]")==""){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.showDialog(2,"提示","请填写完整必填项<span class='required'>(*)</span>",btns,280,130);
		return;
	}
	popwin.loading();
	ajaxPost("adform","ad_ajax.php?action=edit&id={$id}",ajax_editad_callback);
}

function ajax_editad_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"编辑成功","添加/编辑广告成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

	</script>
EOT;

	break;
	/************************************** edit END ************************************************/

	/************************************** listanc BEGIN ************************************************/
	case "listanc":
	require_once('../inc/pager.php');
	$curPage = numFilter($_GET["page"]);
	$pager = new Pager();
	$pager->init(10,$curPage,"admin.php?inc=ad&action=listanc&page={page}");
	$rows = $pager->queryRows($db,"announces", "" , "*","ordernum, id desc");

	$dwidth=array(0,40,40,200,80,180,150,90);

echo <<<EOT
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="anclistform" onsubmit="return false;">
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1" width="100%">
			<tr style="font-weight:bold;color:#333333;"><td class="td_6"><div class="rowdiv_0" style="width:{$dwidth[1]}px;"><span class="warning">删除</span></div><div class="rowdiv_0" style="width:{$dwidth[2]}px;">顺序</div><div class="rowdiv_0" style="width:{$dwidth[3]}px;">标题</div><div class="rowdiv_0" style="width:{$dwidth[4]}px;">类型</div><div class="rowdiv_0" style="width:{$dwidth[5]}px;">显示位置 / 展示时间</div><div class="rowdiv_0" style="width:{$dwidth[6]}px;">作者 / 发布时间</div><div class="rowdiv_0" style="width:{$dwidth[7]}px;">操作</div></td></tr>
		</table>
		<div id="linksdiv">
EOT;
			foreach($rows as  $row){
				
				$row['posttime']=getDateStr($row['posttime']);
				$row['starttime']=empty($row['starttime'])?"无限制":getDateStr($row['starttime'],'dateonly',false);
				$row['stoptime']=empty($row['stoptime'])?"无限制":getDateStr($row['stoptime'],'dateonly',false);
				$row['title']=htmlFilter($row['title']);
				$row['username']=htmlFilter($row['username']);
				$rowtype = numFilter($row['type'])==1?'链接':'文本';
				$rowlink = numFilter($row['type'])==1? $row['url']:"../announce.php?id=$row[id]";
				$rowforum=$row['fid']==0?"自定义":$cache_forums[$row['fid']]['forumname'];

				echo("<table class=\"table_1\" width=\"100%\"><tr><td class=\"td_6\">
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[1]}px;\"><input type=\"checkbox\" value=\"{$row['id']}\" name=\"delid[]\" class=\"checkbox_css\" /></div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[2]}px;\"><input type=\"text\" value=\"{$row['ordernum']}\" size=\"2\" name=\"ordernum[{$row['id']}]\" class=\"text_css\" /></div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[3]}px;\"><a class=\"title\" href=\"{$rowlink}\" target=\"_blank\"><span style=\"color:{$row['color']}\">{$row['title']}</span></a></div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[4]}px;\">{$rowtype}</div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[5]}px;\">{$rowforum}<br /><span class=\"time\">{$row['starttime']}</span> ~ <span class=\"time\">{$row['stoptime']}</span></div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[6]}px;\"><a href=\"../user.php?uid={$row['userid']}\" target=\"_blank\">{$row['username']}</a><br /><span class=\"time\">{$row['posttime']}</span></div>
				<div class=\"rowdiv_0\" style=\"width:{$dwidth[7]}px;\"><a href=\"admin.php?inc=ad&action=editanc&ancid={$row['id']}\">编辑</a></div></td></tr></table>");	
			}
			
echo <<<EOT
		</div>
			<table class="table_1" width="100%">
			<tr><td class="td_6"><a class="td_5_1a" href="admin.php?inc=ad&action=editanc"><img src="images/ico_add.gif" border="0" /> 添加公告</a></td></tr>
		</table>
		</form>
	<table width=100%><tr><td><input class="button_css" type="button" value="  提  交  " onclick="ajax_doannounces()" /></td><td><div class="pagestrdiv">{$pager->getPageStr()}</div></td></tr></table>

	</div>
	<div id="t2"></div>
	<div id="t3"></div>
	<div class="div_clear" style="height:30px;"></div>
<script>

var smallNowTab;
var pt = new Tabs();
pt.classpre="smalltab_";
pt.container = "smalltab_container";
pt.createTab("t1","公告管理","",true,"n");
pt.init = function(){
	smallNowTab = pt.nowTab;
};
pt.onclick = function(){
	smallNowTab = pt.nowTab;
};		
pt.initTab();
pt.clickNowTab();


function ajax_doannounces(){
	popwin.loading();
	ajaxPost("anclistform","ad_ajax.php?action=doannounces",ajax_doannounces_callback);
}


function ajax_doannounces_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","批量操作成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

</script>

EOT;
	break;
	/************************************** listanc END ************************************************/


	/************************************** editanc BEGIN ************************************************/
	case "editanc":	//公告
	$ancid=numFilter($_GET['ancid']);
	if(!empty($ancid)){
		$ancrow=$db->row_select_one("announces","id={$ancid}");
		$ancrow['starttime']=empty($ancrow['starttime'])?"":getDateStr($ancrow['starttime'],'dateonly',false);
		$ancrow['stoptime']=empty($ancrow['stoptime'])?"":getDateStr($ancrow['stoptime'],'dateonly',false);
	}
echo <<<EOT
	<style>
	.td_1{width:600px;}
	</style>
	<div id="smalltab_container"></div>
	<div class="smalltab_line"></div>
	<div class="div_clear" style="height:10px;"></div>
	<div id="t1">
		<form id="ancform" onsubmit="return false;">
		<div class="tips_1"><b>广告添加/编辑</b><br />
		* 点击图片可以查看广告的位置/效果图。
		</div>
		<div class="div_clear" style="height:10px;"></div>
		<table class="table_1">
			<tr><td class="td_0">标题:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><input type="hidden" size="3" name="ancid" id="ancid" value="{$ancrow['id']}" class="text_css" /><input type="hidden" size="3" name="fid" id="fid" value="{$fid}" /><input type="text" size="50" style="color:{$ancrow['color']}" name="anc[title]" id="anc[title]" value="{$ancrow['title']}" class="text_css" /> 颜色:<img src="../images/ico_color.gif" align="absmiddle" border="0" id="img_color" class="colorpicker" /><input type="hidden" size="7" class="admin_color" name="anc[color]" id="anc[color]" value="{$ancrow['color']}" /></td><td class="td_2">广告名称只为识别辨认不同广告条目之用，并不在广告中显示</td></tr>
			<tr><td class="td_0">展示时间:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="11" name="anc[starttime]" id="anc[starttime]" value="{$ancrow['starttime']}" class="text_css" /> ~ <input type="text" size="11" name="anc[stoptime]" id="anc[stoptime]" value="{$ancrow['stoptime']}" class="text_css" /></td><td class="td_2">设置广告显示的时间，格式 yyyy-mm-dd，留空为不限制时间</td></tr>
			<tr><td class="td_0">展示版块:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><select size="10" multiple="multiple" style='width:280px;' name="anc[targets]" id="anc[targets]"><option value="all">全部</option><option value="index">首页</option>{$cache_forumsoption2}</select></td><td class="td_2">设置显示的范围，可以按住 CTRL 多选</td></tr>
			<tr><td class="td_0">类型:<span class="required">(*)</span></td><td class=""></td></tr>
			<tr><td class="td_1"><select name="anc[type]" id="anc[type]" style="width:100px;"><option value="0">文本</option><option value="1">链接</option></select></td><td class="td_2">设置允许参与搜索的用户组，可以按住 CTRL 多选</td></tr>
			<tr><td class="td_0">链接:</td><td class=""></td></tr>
			<tr><td class="td_1"><input type="text" size="80" name="anc[url]" id="anc[url]" value="{$ancrow['url']}" class="text_css" /></td><td class="td_2">广告名称只为识别辨认不同广告条目之用，并不在广告中显示</td></tr>
			<tr><td class="td_0">内容:</td><td class=""></td></tr>
			<tr><td class="td_1"><textarea style="display:none;" name="anc[content]" id="anc[content]">{$ancrow['content']}</textarea><iframe ID="Editor" name="Editor" src="../inc/editor/ubb/editor.htm?ubb=1&id=anc[content]&frmid=Editor" frameBorder="0" marginHeight="0" marginWidth="0" scrolling="No" style="height:200px;width:580px"></iframe></td><td class="td_2">广告名称只为识别辨认不同广告条目之用，并不在广告中显示</td></tr>
			<tr><td class="td_3"><input class="button_css" type="button" value="  提 交  " onclick="ajax_announces()" /></td><td class=""></td></tr>
		</table>
		</form>
	</div>
	
	<div class="div_clear" style="height:30px;"></div>
	<script>
	var ancid="{$ancid}";

	var smallNowTab;
	var pt = new Tabs();
	pt.classpre="smalltab_";
	pt.container = "smalltab_container";
	pt.createTab("t1","公告添加/编辑","",true,"n");
	pt.init = function(){
		smallNowTab = pt.nowTab;
	};
	pt.onclick = function(){
		smallNowTab = pt.nowTab;
	};		
	pt.initTab();
	pt.clickNowTab();

if(ancid!=""){
	setSelect("anc[type]","{$ancrow['type']}");
	var targets="{$ancrow['targets']}";
	var ts=targets.split(",");
	for(var i=0;i<ts.length;i++){
		setSelect("anc[targets]",ts[i]);
	}
}

function ajax_announces(){
	if(getV("anc[title]")==""||getV("anc[targets]")==""){
		var btns=[{value:" 确 定 ",onclick:"popwin.close();",focus:true}];
		popwin.showDialog(2,"提示","请填写完整必填项<span class='required'>(*)</span>",btns,280,130);
		return;
	}
	Editor.attachSubmit();
	popwin.loading();
	ajaxPost("ancform","ad_ajax.php?action=postannounces",ajax_announces_callback);
}
function ajax_announces_callback(data){
	var btns=[{value:" 确 定 ",onclick:"popwin.close();mainifm.location.reload();",focus:true}];
	popwin.loaded();
	if(data=="y"){
		popwin.showDialog(1,"操作成功","公告发布/编辑成功",btns,280,130);
	}else{
		popwin.showDialog(0,"操作失败","操作失败:<br />"+data,btns,280,130);
	}
}

function checkFormSubmit(){
	return false;
}

function PageInit(){
	E("anc[starttime]").onfocus = function(){choosedate.dfd(E('anc[starttime]'))};
	E("anc[stoptime]").onfocus = function(){choosedate.dfd(E('anc[stoptime]'))};
	E("anc[color]").onfocus = function(event){colorpicker.choose(event)};
	E("img_color").onclick = function(event){colorpicker.choose(event)};
	var ancid="{$ancrow['id']}";
	var anctype ="{$ancrow['type']}";
	if(ancid!=""){
		setSelect("anc[type]",anctype);
	}

	colorpicker.previewColor = function(color){
		color=color==""?"#000000":color;
		E("anc[title]").style.color = color;
		E("anc[color]").value = color;
	}
	colorpicker.chooseColor = function(color){
		color=color==""?"#000000":color;
		E("anc[title]").style.color = color;
		E("anc[color]").value = color;
	}
}
window.onload=PageInit;

	</script>
EOT;

	break;
	/************************************** editanc END ************************************************/

}	
?>